package Air_war;

import java.awt.image.BufferedImage;
import java.util.Random;
//小蜜蜂类
public class Bee extends FlyingObject{
    private int xspeed;
    private int yspeed;
    private int awardType;//奖励类型

    public Bee(){
        super(60,51);
        xspeed = 1;
        yspeed = 2;
        Random rand = new Random();
        awardType = rand.nextInt(2);//奖励类型随机
    }
    //重写step 移动
    public void step(){
        x+=xspeed;
        y+=yspeed;
        if(x<=0 || x>=World.WIDTH-width) {
            xspeed*=-1;
        }

    }



    int index = 1;
    public BufferedImage getImage() {
        if(isLive()) {//若为活着的
            return Images.bees[0];//活着直接返回airs[0]即可
        }else if(isDead()) {//若为死了的
            BufferedImage img = Images.bees[index++];//爆破图1--4
            if(index==Images.bees.length) {//若爆破图走到跟airs数组一样长的时候
                state = REMOVE;//等于到删除
            }
            return img;
        }//若为删除的
        return null;//直接返回null 不返回图片
    }
    //重写getAwardType获取奖励
    public int getAwardType(){
        return awardType;//返回奖励类型
    }
}
